package com.base.core.mvc.ws;

import com.base.core.context.mvc.Constants;
import com.gitee.magic.framework.base.constant.Config;

/**
 * 
 * @author zywei
 *
 */
public class WsState {
	
	private final static String WEBSOCKET_USERID="WEBSOCKET_USERID";
	private final static String WEBSOCKET_CHANNEL="WEBSOCKET_CHANNEL";
	
	/**
	 * 获取用户Id唯一KEY
	 * @param userId
	 * @return
	 */
	public static String getWebSocketUserId(String userId) {
		return Constants.getKey(WEBSOCKET_USERID,userId);
	}
	
	/**
	 * 全局服务KEY
	 * @return
	 */
	public static String getWebSocketGlobalChannel() {
		return Constants.getKey(WEBSOCKET_CHANNEL);
	}

	/**
	 * 获取服务唯一KEY(分布式部署每个节点ID不一样)
	 * @return
	 */
	public static String getWebSocketServiceChannel() {
		return Constants.getKey(WEBSOCKET_CHANNEL, Config.getBalancedDataCenterId(),Config.getBalancedWorkerId());
	}

}
